// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Camera focus on object
// -----------------------------------------------

private ["_cam","_grave","_position"];

waitUntil {isNull wccam};
waitUntil {!(player getVariable "deadmarker")};

//A3 TODO: setVehicleInit
player setVehicleInit "this allowDammage true;";
processInitCommands;

_cam = "camera" camCreate [0, 0, 1000];
_cam cameraEffect ["internal", "back"];
showCinemaBorder true;

playMusic "outro";

_position = (getMarkerPos "respawn_west") findEmptyPosition [10, 200];
if (_position select 0 == 0) then {
	diag_log "WARCONTEXT: CANNOT FIND EMPTY POSITION FOR PLAYER OUTRO";
	player setPos wcmapcenter;
} else {
	player setPos _position;
};

//A3 TODO: Mortuary
while {true} do {
	_grave = nearestObjects [getMarkerPos "mortuary", [["gravecross2", "GraveCrossHelmet"] call BIS_fnc_selectRandom], 200];
	_cam camSetTarget getPosATL (_grave call BIS_fnc_selectRandom);
	_cam camSetRelPos [0, -4, 1];
	_cam camCommit 8;
	sleep 8;
	titleRsc ["LooseMission", "Plain", 2];
	_cam camSetRelPos [0, -4, 1];
	_cam camCommit 0;

	sleep 4;
};

wccam = objNull;